set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

" let Vundle manage Vundle " required! 
Bundle 'gmarik/vundle'
" :BundleList          - list configured bundles
" :BundleInstall(!)    - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" NOTE: comments after Bundle command are not allowed..

" github repos 
Bundle 'tpope/vim-rails.git'
Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/nerdcommenter'

" vim-scripts repos
Bundle 'L9'
Bundle 'FuzzyFinder'
Bundle 'grep.vim'
Bundle 'rails.vim'
Bundle 'SuperTab'
Bundle 'Align'

" non github repos

"=============================================================================
" 1. General settings
"=============================================================================
set nocompatible        

let mapleader=","

filetype on
filetype plugin on 
filetype plugin indent on

syntax enable
syntax on

set t_Co=256
set hlsearch            "high light search result
set background=dark     "background color 
colorscheme ron         "color scheme 

set nu              "line number
set numberwidth=1   "line number width

set backspace=indent,eol,start    "when indent/eol/start, we can backspace 
set autoindent      "auto indent
set expandtab       "use space instead of tab
set tabstop=2       "tab 2 space
set shiftwidth =2   "indent 2 space


set linebreak              "do not wrap in a word
set whichwrap=b,s,<,>,[,]  "when we can wrap
set fo+=mB                 "support wrap for Asian char
set linebreak

set nolist                    "show char space and tab
set listchars=tab:>-,trail:-  "show what char when space and tab 

set cursorline    "horizontal line
set showmatch     "show match char
set matchtime=5   "show match char time
set ruler         "show the cursor position all the time

set cmdheight=1         "command line height
set showcmd             "display incomplete commands
set history=50          "keep 50 lines of command line history
set laststatus=2

set statusline=FILE_NAME=%F%m%r%h%w,\ FILE_TYPE=%Y,\ FILE_CODE=%{&ff},\ ASCII=\%03.3b\,\ HEX=\%02.2B\,\ %l,%v(%L)\ %p%%

set nobackup           "no backup file
set nowritebackup      "no write backup

set encoding=utf-8
let &termencoding=&encoding
set fileencodings=utf-8,gbk,ucs-bom,cp936

set guifont=Monaco\ 12

set foldenable
set foldmethod=syntax
set foldlevel=100
set foldopen-=search
set foldopen-=undo

"=============================================================================
" 3 Edit
"=============================================================================
"align {
":15,16Align=>
autocmd BufReadPost *.rb silent! AlignCtrl p1P1 
vmap <F4> :Align=><CR>
vmap <F5> :Align=<CR>
"}

"=============================================================================
" 5 search
"=============================================================================
"Grep {
" :Grep :Rgrep
let s:os = system("uname")
if s:os =~ "Darwin"
  let g:Grep_Xargs_Options='-0'
endif
let Grep_Shell_Quote_Char = '"'
let Grep_Skip_Dirs = '.svn'
nnoremap <silent> <F3> :Rgrep -i --exclude=*.svn-base --exclude=*tags --exclude=*.log --exclude=*.swp --exclude=*.tmp<CR>
"}

"FuzzyFinder {
let g:fuf_modesDisable = ['mrucmd']
let g:fuf_ignoreCase = 1
let g:fuf_abbrevMap  = {
	 \"^co:" : [
	 \       "app/controllers/**/",
	 \],
	 \"^mo:" : [
	 \       "app/models/**/",
	 \],
	 \"^hp:" : [
	 \       "app/helpers/**/",
	 \],
	 \"^vi:" : [
	 \       "app/views/**/",
	 \],
	 \"^js:" : [
	 \       "public/javascripts/**/",
	 \],
	 \"^ss:" : [
	 \       "public/stylesheets/**/",
	 \],
	 \"^li:" : [
	 \       "lib/**/",
	 \],
	 \}

nmap ff :FufFile<cr>
nmap fc :FufFile co:<cr>
nmap fm :FufFile mo:<cr>
nmap fh :FufFile hp:<cr>
nmap fv :FufFile vi:<cr>
nmap fj :FufFile js:<cr>
nmap fs :FufFile ss:<cr>
nmap fl :FufFile li:<cr>

nmap fb :FufBuffer<cr>
nmap fn :FufLine <CR>
nmap fr :FufMruFile <CR>
"}

"=============================================================================
" 8 Comments
"=============================================================================
"NERD_commenter {
let NERD_c_alt_style = 1
map cm ,c<space>gv
vmap cm ,c<space>
"}

"=============================================================================
" 9 windows & tab 
"=============================================================================
"General Command {
" <c-w><c-w> " switch windows
" :sp :vsp
nmap <silent> mm <C-W>w:set cursorline<CR>:200sl m<CR>:set nocursorline<CR>
nmap <silent> <S-m> <C-W>p:set cursorline<CR>:200sl m<CR>:set nocursorline<CR>
nmap <C-N> :tabnext<CR>
nmap <C-P> :tabprev<CR>
"}
  
"NERDTree {
nnoremap <silent> <F2> :NERDTreeToggle<CR>
let NERDChristmasTree=1
let NERDTreeAutoCenter=1
let NERDTreeShowFiles=1
"let NERDTreeShowHidden=1
let NERDTreeShowLineNumbers=1
let NERDTreeWinPos='left'
let NERDTreeWinSize=21
"}
